<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>施工单位 审批</title>
<link rel="stylesheet" href="css/vivo.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap-table.css">
<link rel="stylesheet" href="css/common.css">
<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="js/webuploader-0.1.5/webuploader.css" />

<script src="js/jquery-1.11.1.js"></script>
<script src="js/bootstrap2/js/bootstrap.min.js"></script>

<script src="js/bootstrap2/js/bootstrap-table.js"></script>
<script src="js/bootstrap2/js/bootstrap-table-zh-CN.js"></script>
<script src="js/select2/select2.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="js/webuploader-0.1.5/webuploader.js"></script>
<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script> 
<script type="text/javascript" src="js/sharefunction.js"></script> 
<script type="text/javascript" src="js/form.js"></script> 
<!-- 图片放大 -->
<script src="js/postbird-img-glass/postbird-img-glass.js" ></script>
<script>
	$(function() {
		//禁用表单和按钮
		hideButton();
		//悬浮提示
		toolTip();
		//修改字段标记记录变量
		<c:set var="marks" value="原数据"/>
		//附件赋值
		initProofreadFile();
	});
	
	function save(opt){
		var url = "customer/dm/disposeProofRead";
		var apId = '${requestScope.apId }';
		var exDataId = '${exDataId}';
		var approvalRemark = $("textarea[name='approvalRemark']").val();
		var formData = {
				exDataId:exDataId,
	        	opt:opt,
	        	apId:apId,
	        	approvalRemark:approvalRemark
	    };
		disposeSave(opt,url,formData);
	}
	
</script>
</head>

<body>
<!-- 核准材料 -->
<div>
	<!-- 表单开始 -->
	<form id="proofreadForm" method="post">
		<input type="hidden" id="proofread_articleId">
		<div class="panel panel-default">
			<div class="panel-body ">
				<table cellpadding="10" cellspacing="5" class="mytable">
					<tr>
						<td width="90"><span class="style_btn">施工单位</span></td>
						<td>
							<select id="proofreads2" style="width: 200px;" >
								<option value="${du.id}">${du.unitName }</option>
							</select>
							<c:if test="${not empty requestScope.map.unitName }"><span class="toolTip mark-msg"data-tip="${requestScope.map.unitName }">
								<c:out value="${marks}"/></span>
							</c:if>
							<c:if test="${requestScope.map.unitName=='' }"><span class="toolTip mark-msg"data-tip="空">
								<c:out value="${marks}"/></span>
							</c:if>
						</td>
					</tr>
					<tr>
						<td width="90"><span class="style_btn">装修管理协议</span></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_zxgl'></div> <!-- 上传按钮 -->
							<div id='filePicker_zxgl' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">安全协议</span></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_aqxy'></div> <!-- 上传按钮 -->
							<div id='filePicker_aqxy' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">动火作业许可证</span></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_dhzy'></div> <!-- 上传按钮 -->
							<div id='filePicker_dhzy' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">临时电源许可证</span></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_lsdy'></div> <!-- 上传按钮 -->
							<div id='filePicker_lsdy' style="display: none">上传</div>
						</td>
					</tr>
					<tr>
						<td><span class="style_btn">开工许可证</span></td>
						<td>
							<!-- 缩略图容器 -->
							<div id='list_kgxk'></div> <!-- 上传按钮 -->
							<div id='filePicker_kgxk' style="display: none">上传</div>
						</td>
					</tr>
				</table>
				
			</div>
		</div>
		<input name="proofreadId" id="entityId_id" value="${id}" hidden="hidden"/>
		<input type="hidden" id="apId" name="apId" value="${requestScope.apId }"/>
		<c:if test="${requestScope.notPassExamine}">
			<!-- 修改时添加变更说明 -->
			<div style="margin:10px;" id="approvalRemark">
				审批意见<textarea rows="3" name="approvalRemark"style="width:70%"></textarea><span style="color:red;">*</span>
			</div>
			<div style="width:100%;text-align:center; padding-top:0px">
				<button class="btn btn-danger radius my-btn"
					onclick="save(0)" type="button">同意</button>
				<button class="btn btn-default radius"
					onclick="save(1)" type="button">拒绝</button>
			</div>
		</c:if>
	</form>
	<!-- 表单结束 -->
	<script type="text/javascript">
		function initProofreadFile(){
			var proofreadEntityId = $("#proofreadForm").find("#entityId_id").val();
			//获取附件数据					
			getFileListByFlag(proofreadEntityId,"装修管理协议",2,"#list_zxgl",setProofRFL,imgPlus);
			getFileListByFlag(proofreadEntityId,"安全协议",2,"#list_aqxy",setProofRFL,imgPlus);
			getFileListByFlag(proofreadEntityId,"动火作业许可证",2,"#list_dhzy",setProofRFL,imgPlus);
			getFileListByFlag(proofreadEntityId,"临时电源许可证",2,"#list_lsdy",setProofRFL,imgPlus);
			getFileListByFlag(proofreadEntityId,"开工许可",2,"#list_kgxk",setProofRFL,imgPlus);
			<c:if test="${requestScope.notPassExamine}"> 
			//编辑新加的图片数据
			var fileCas=${requestScope.caList};
			if(fileCas.length > 0){
				var zxgl = "";//装修管理协议
				var aqxy = "";//安全协议
				var dhzy = "";//动火作业许可证
				var lsdy = "";//临时电源许可证
				var kgxk = "";//开工许可
				for(var i=0;i<fileCas.length;i++){
					if(fileCas[i].articleId == "装修管理协议"){
						zxgl += (","+fileCas[i].accessoryCAId);
					}else if(fileCas[i].articleId == "安全协议"){
						aqxy += (","+ fileCas[i].accessoryCAId);
					}else if(fileCas[i].articleId == "动火作业许可证"){
						dhzy += (","+ fileCas[i].accessoryCAId);
					}else if(fileCas[i].articleId == "临时电源许可证"){
						lsdy += (","+ fileCas[i].accessoryCAId);
					}else if(fileCas[i].articleId == "开工许可"){
						kgxk += (","+ fileCas[i].accessoryCAId);
					}
				}
				if(zxgl != ""){
					getFileTempList(zxgl.substring(1),"#list_zxgl", setProofRFL, imgPlus);
				}
				if(aqxy != ""){
					getFileTempList(aqxy.substring(1), "#list_aqxy", setProofRFL, imgPlus);
				}
				if(dhzy != ""){
					getFileTempList(dhzy.substring(1),"#list_dhzy", setProofRFL, imgPlus);
				}
				if(lsdy != ""){
					getFileTempList(lsdy.substring(1),"#list_lsdy", setProofRFL, imgPlus);
				}
				if(kgxk != ""){
					getFileTempList(kgxk.substring(1),"#list_kgxk", setProofRFL, imgPlus);
				}
			}
			</c:if>
		}
		
		function hideButton(){
			//锁定表单
			$("#proofreadForm select").attr("disabled",true);
			$("#proofreadForm input[name='file']").attr("disabled",true);
			//禁止点击上传按钮
			$("#proofreadForm div[id^='filePicker']").hide();
		}
		//本页面图片放大通用方法,同时隐藏上传按钮与图片删除按钮
		function imgPlus(data){
			$.each(data,function(i,v){
				hideFileBtn(v.id);
				PostbirdImgGlass.init({
			    	domSelector:"img",
			    	animation:true,
			    	//height:'80%',
			    	myDocument:window.parent.parent.parent
				});
			});
		}
		//隐藏附件删除按钮
		function hideFileBtn(id){
			//$("#"+id+" span.uploadcancel").hide();
			$(".uploadcancel").hide();
		}
		
		//设置待删除附件的值到集合中
	function setProofRFL(id,_this){
		layer.confirm('删除该图片？',{
			title:'警告',
			icon:0,
			shade:[0.1, '#fff']
		},function(){
			proofFuidList.push(id);
			//删除指定缩略图
			$("#"+id).remove();
			layer.close(layer.index);
		});
	}
	</script>
</div>
</body>
</html>